#!/bin/bash

function log() {
	if [[ -t 1 ]]; then
		printf "\x1b[1m\x1b[32m>>>\x1b[0m \x1b[1m%s\x1b[0m\n" "$1"
	else
		printf ">>> %s\n" "$1"
	fi
}

test_dir="${0%/*}"
error=0

for test in "$test_dir/"*_test.sh; do
	log "Running $test under $SHELL (interactive) ..."
	"$SHELL" $* -i "$test" || error=1
	echo
done

for test in "$test_dir"/*_test.sh; do
	log "Running $test under $SHELL (non-interactive) ..."
	"$SHELL" $* "$test" || error=1
	echo
done

exit "$error"
